package com.broadengate.action;


import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.broadengate.model.Deposit;
import com.broadengate.model.Transfer;
import com.broadengate.model.Withdraw;
import com.broadengate.service.AdminService;


public class AdminHistoryAction extends DispatchAction{
	private AdminService adminService;

	
	/******
	 * 管理员查看所有用户在此ATM取款机的操作记录，
	 * 核心功能由调用AdminService对象的方法depositList()，withdrawList()，trasferList()实现
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward 对象
	 */
	public ActionForward getHistory(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response){
		
		List<Deposit> depositList = adminService.depositList();
		List<Withdraw> withdrawList = adminService.withdrawList();
		List<Transfer> transferList = adminService.trasferList();
		
		request.setAttribute( "depositListAdmin", depositList );
		request.setAttribute( "withdrawListAdmin", withdrawList );
		request.setAttribute( "transferListAdmin", transferList );
							
		String type=request.getParameter("type");
		if(type.equals("1")){
			return mapping.findForward("success1");
		}
		else if(type.equals("2")){
			return mapping.findForward("success2");
		}
		else if(type.equals("3")){
			return mapping.findForward("success3");
		}
		else
		return mapping.findForward("fail");
	}

	public AdminService getAdminService() {
		return adminService;
	}

	public void setAdminService(AdminService adminService) {
		this.adminService = adminService;
	}
}
